import axios from "axios";
import config from "@/config/config.js";

const toolsTypeRequest={
    loadToolType(type,page=1,limit=10,callBack){
        let url = config.toolBaseUrl+"/type/list?page="+page+"&limit="+limit;
        if (type){
            if (type.toolTypeCode){
                url += "&toolTypeCode=" +type.toolTypeCode;
            }
            if (type.toolTypeName){
                url += "&toolTypeName=" +type.toolTypeName;
            }
            if (type.maintainType){
                url += "&maintainType=" +type.maintainType;
            }
            axios.get(url).then(res=>{
                callBack(res.data);
            })
        }
    },

    addToolType(type,callBack){
        let url =config.toolBaseUrl +"/type/add";
        axios.put(url,type).then(res=>{
            callBack(res.data);
        })
    },

    deleteToolTYpe(typeId,callBack){
        let url = config.toolBaseUrl +"/type/delete?toolTypeId="+typeId;
        axios.put(url).then(res=>{
            callBack(res.data);
        })
    },

    updateType(type,callBack){
        let url = config.toolBaseUrl +"/type/updateType";
        axios.put(url,type).then(res=>{
            callBack(res.data);
        })
    },

    selectById(typeId,callBack){
        let url = config.toolBaseUrl + "/type/selectById?toolTypeId="+typeId;
        axios.get(url).then(res=>{
            callBack(res.data);
        })
    }
}
export default toolsTypeRequest;